//
//  UIView+HH2Rect.m
//  JiPei
//
//  Created by hh on 16/1/30.
//  Copyright © 2016年 hh. All rights reserved.
//

#import "UIView+HH2Rect.h"

@implementation UIView (HH2Rect)

- (CGFloat)x;
{
    return self.frame.origin.x;
}
- (void)setX:(CGFloat)x
{
    CGRect rect = self.frame;
    rect.origin.x = x;
    self.frame = rect;
}
- (CGFloat)y
{
    return self.frame.origin.y;
}
- (void)setY:(CGFloat)y
{
    CGRect rect = self.frame;
    rect.origin.y = y;
    self.frame = rect;
}
- (CGFloat)width
{
    return self.frame.size.width;
}
- (void)setWidth:(CGFloat)width
{
    CGRect rect = self.frame;
    rect.size.width = width;
    self.frame = rect;
}
- (CGFloat)height
{
    return self.frame.size.height;
}
- (void)setHeight:(CGFloat)height
{
    CGRect rect = self.frame;
    rect.size.height = height;
    self.frame = rect;
}

-(CGPoint)origin
{
    return self.frame.origin;
}
- (void)setOrigin:(CGPoint)origin
{
    CGRect rect = self.frame;
    rect.origin = origin;
    self.frame = rect;
}
-(CGSize)size
{
    return self.frame.size;
}
- (void)setSize:(CGSize)size
{
    CGRect rect = self.frame;
    rect.size = size;
    self.frame = rect;
}

- (CGFloat)rightX
{
    return self.x + self.width;
}
- (CGFloat)bottomY
{
    return self.y + self.height;
}
- (CGFloat)midX
{
    return self.center.x;
}
- (CGFloat)midY
{
    return self.center.y;
}
- (CGPoint)midPoint
{
    return CGPointMake(self.width/2, self.height/2);
}

@end
